<template>
	<view class="body">
		<view class="inf">
			<el-input placeholder="输入患者姓名" style="margin-bottom: 50rpx;" v-model="name"></el-input>
			<el-input placeholder="输入患者身份证号" style="margin-bottom: 50rpx;" v-model="id"></el-input>
			<view style="display: flex;flex-direction: row; width: 100%; justify-content: space-around;">
				<el-button type="primary" @click="submitInf">提交信息</el-button>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import {ref} from 'vue';
	import axiosInstance from '@/Config/axiosConfig'
	import globalStore from '@/store/GlobalStore';
	import Emessage from '@/Utils/Message';
const name=ref("");
const id=ref("")
const phone=ref("");
const code=ref("");
//提交患者信息
const submitInf=async()=>{
	
	if(""==name.value||null==name.value){Emessage("未填写患者姓名");return;}
	if(""==id.value||null==id.value){Emessage("未填写身份证号");return;}
	try{
	const response=await axiosInstance.get('/patient/addDetail?idNumber='+id.value+"&name="+name.value)
	if(response.data.code==200){
		globalStore.patientid=response.data.data;
		uni.navigateTo({
			url:'/pages/Home/Home'
		})
		globalStore.messageMap.set("PATIENTNAME",name.value);
		globalStore.messageMap.set("PATIENTIDNUMS",id.value);
		
	}else Emessage(response.data.message,"error");
	}catch(e){
		Emessage("网络错误","error")
	}

}
</script>

<style>
.body{
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100vh;
	justify-content: space-around;
	align-items: center;
}
.inf{
	display: flex;
	flex-direction: column;
	width: 80%;
	height: 80%;
	justify-content: flex-center;
	align-items: center;
}
</style>
